home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / dosfltrs.arc / FILTERS.DOC < prev    next >
Encoding:
Text File  |  1984-11-10  |  8.1 KB  |  242 lines

  1. Documentation for the DOS 2.1 (and probably 2.0) filters
  2.  
  3.     Upper    | translate all lowercase characters to uppercase
  4.     Lower    | translate all uppercase characters to lowercase
  5.     Snglspc    | removes extra blank lines from a file
  6.     Unique    | deletes multiple occurances from a sorted list
  7.     Trunc    | truncates a line at first matching char (or space)
  8.     Fecho    | echoes standard input to screen (great for debugging)
  9.     Translat| puts each word of a file onto a separate line.
  10.     Feed    | reads a filespec and sends files to standard output
  11.     Forclean| takes a fortran source and deletes comments and labels
  12.  
  13. ========================================================================
  14.  
  15. Filters in general:
  16.  
  17.     In case you have never played with MORE, FIND, or SORT in
  18.     DOS 2.0 and DOS 2.1, here is a brief explanation of what they
  19.     are and what they do.
  20.  
  21.     Filters are special programs that always read their data from
  22.     something called "standard input" and send their output to
  23.     "standard output".  Standard input is usually the keyboard, and
  24.     standard output is usually the screen.  However, both of these
  25.     can be "redirected" wherever you want them to go using the
  26.     "<" and ">" symbols.  For example,
  27.  
  28.         SORT <INPUT.DAT >OUTPUT.DAT
  29.  
  30.     causes the SORT filter to read its input from INPUT.DAT, sort
  31.     that data, and place the sorted output into OUTPUT.DAT.
  32.     If you tried
  33.  
  34.         SORT <INPUT.DAT
  35.  
  36.     SORT would get its input from INPUT.DAT and send the sorted
  37.     data to the screen.
  38.  
  39.     Can you guess what the next line will do?
  40.  
  41.         SORT >OUTPUT.DAT
  42.  
  43.     That's right, it will read its data from the keyboard and
  44.     send the sorted output to the file OUTPUT.DAT!  This means
  45.     that sort will wait for you to type data, and will continue
  46.     to read your data until you either stop the input with a
  47.     Control-Z (or F6), run out of memory, or turn off the machine!
  48.     After you enter F6, the sorted data will appear on the screen.
  49.  
  50.     For a useful example of this, try
  51.  
  52.         DIR *.BAS >DIR.LST
  53.         SORT <DIR.LST >DIRSORT.LST
  54.  
  55.     (There is a neater way to this, which I'll get into soon.)
  56.  
  57.     MORE is a filter, too, with (I presume) some forced reads
  58.     from the keyboard at each pause.
  59.  
  60.     FIND is also a filter, but it can read parms from the command
  61.     line (like MORE should, but doesn't.)  The first parm it
  62.     wants is a search string in double quotes.  The second parm
  63.     is an optional file name.  If you don't supply a filename, FIND
  64.     will read standard input.
  65.  
  66. Now for pipes:
  67.  
  68.     PIPES and FILTERS originally appeared in UNIX.  PIPES are
  69.     much more powerful in UNIX than DOS 2.0, but even ours can
  70.     be very useful.
  71.  
  72.     PIPES, simply put, are several FILTERS strung out with each
  73.     FILTER's output becoming the input to the next.  For example,
  74.     the sorted directory listing in the last example could have
  75.     been produced with
  76.  
  77.         DIR *.BAS | SORT >DIRSORT.LST
  78.  
  79.     This would result in the same thing but doesn't leave extra
  80.     files hanging around (like DIR.LST in the previous example.)
  81.  
  82.     The "|" (located above the backslash "\" and next to "z") is the
  83.     symbol for a PIPE and is best used with spaces before and
  84.     after.  Sometimes DOS has problems separating the "|" from
  85.     filenames in the parameters and get confused if the "|" is
  86.     not preceeded by a space.
  87.  
  88. ========================================================================
  89.  
  90. Now for the new FILTERS:
  91.  
  92.     UNIX has a large number of very useful FILTERS available, which
  93.     inspired several of the FILTERS here.  What follows is a short
  94.     description of each filter and usage examples for the weirder
  95.     ones.
  96.  
  97. ------------------------------------------------------------------------
  98.  
  99. UPPER & LOWER
  100.  
  101.     These two filters work very much alike - they read from
  102.     standard input and translate every character to either
  103.     uppercase (UPPER) or lowercase (LOWER).  Non-alphabetic
  104.     characters are not affected.
  105.  
  106.     Both of these filters will also accept a filename on the
  107.     command line, which means you don't have to use the redirection
  108.     symbol "<" to supply the input data. Note that output data must
  109.     still be redirected.
  110.  
  111.     Examples:
  112.  
  113.         UPPER <BOOK.TXT >BOOKUP.TXT
  114.         LOWER BOOK.TXT >BOOKLOW.TXT
  115.         UPPER TRASH.TXT
  116.         etc...
  117.  
  118. ------------------------------------------------------------------------
  119.  
  120. UNIQUE
  121.  
  122.     This filter reads a SORTED list and removes multiple occurances
  123.     of IDENTICAL lines.
  124.  
  125.     Example:
  126.  
  127.         LOWER BOOK.TXT | TRANSLAT | SORT | UNIQUE >WORDS.TXT
  128.  
  129.     WORDS.TXT new contains a sorted list of all the different words
  130.     contained in BOOK.TXT.
  131.  
  132. ------------------------------------------------------------------------
  133.  
  134. SNGLSPC
  135.  
  136.     This filter reads from standard input and removes blank lines.
  137.     (Blank lines are defined as more than one cr/lf together.)
  138.  
  139. ------------------------------------------------------------------------
  140.  
  141. FEED
  142.  
  143.     This filters accepts a filespec (which can include wildcards!)
  144.     from the command line.  All files which match the filespec
  145.     are opened and the contents are sent to standard output.
  146.     This allows you to redirect the standard input from more than
  147.     one file.  Possible uses are searching a large group of
  148.     files for the occurance of some string, like with FIND.
  149.  
  150.     Example:
  151.  
  152.         FEED *.FOR | FIND "CALL"
  153.  
  154.     This will find all subroutine calls within a series of programs,
  155.     but, unfortunately, won't necessarily supply the name of each
  156.     file containing the "CALL".
  157.  
  158. ------------------------------------------------------------------------
  159.  
  160. TRUNC
  161.  
  162.     This filter reads a file and truncates it starting at the first
  163.     space or any single character you specify on the command line.
  164.     If the character is not found in the line the entire line is
  165.     passed intact.
  166.  
  167.     Example:
  168.  
  169.         DIR *.FOR|TRUNC|SORT >FORTRAN.LST
  170.  
  171.     This line will give you a sorted list of fortran programs that
  172.     does not include extensions.
  173.  
  174.         FEED ???.FOR | FIND "CALL" | TRUNC ( | SORT | UNIQUE
  175.                         >FORCALLS.LST
  176.  
  177.     This line fill search all fortran files for the word "CALL",
  178.     truncate each line at the "(" following the subroutine name
  179.     (if any), sort the list, and delete multiple occurances.  This
  180.     gives me a list of all the subroutines called by my programs.
  181.     Note that any numeric labels in the Fortran code are still
  182.     there and result in extra listings at the bottom of the list.
  183.     The next filter takes care of that.
  184.  
  185. ------------------------------------------------------------------------
  186.  
  187. FORCLEAN
  188.  
  189.     This filter reads Fortran files, deletes all comment lines,
  190.     and deletes numeric labels.  Inserting this before the sort
  191.     in the previous TRUNC example eliminates the extra lines
  192.     at the end of the list, as well as comments that happened to
  193.     contain the word "CALL".  I wrote this one to fill a specific
  194.     need, so it will probably not solve any of your problems.
  195.  
  196. ------------------------------------------------------------------------
  197.  
  198. FECHO
  199.  
  200.     This filter is VERY handy when you are designing a filter
  201.     string of your own.  Placing it in your command allows you to
  202.     see what is going on without disrupting the command itself.
  203.     Specificaly, it reads standard input and sends the data to both
  204.     standard output AND error output (the screen.)
  205.  
  206.     Example:
  207.  
  208.         DIR *.BAS |TRUNC|FECHO|SORT|FECHO|UNIQUE >SRTED.LST
  209.  
  210.     This line contains two FECHO commands, one after the TRUNC and
  211.     the other after the SORT.  This shows you the results of the
  212.     TRUNC command before SORT sees it, and again afterwards.
  213.  
  214. ------------------------------------------------------------------------
  215.  
  216. TRANSLAT
  217.  
  218.     This filter reads a file of text and sends it out one word to a
  219.     line.  Non-alphabetic characters are deleted.  If you were to
  220.     send this file through TRANSLAT what you would see would start
  221.     with:
  222.  
  223.         Documentation
  224.         for
  225.         the
  226.         Dos
  227.         and
  228.         probably
  229.         filters
  230.         .
  231.         .
  232.         .
  233.  
  234. ========================================================================
  235.  
  236.     These filters were written by Joi Ellis of Ventura, Ca.  If you
  237. have any problems or some ideas you would like to see become 'real'
  238. contact me or leave a message on the Oxgate BBS at 682-3486 (24 hours)
  239. or RBBS at 687-9472 (7pm-8am only.)
  240.  
  241.     I hope you find some of these as useful as I have.
  242.